<?php
//error_reporting(0);
//https://feixue.lanzouu.com/iPblx06am0ti
require 'settings.php';
require 'en.php';
$_ = explode('&',GeJISafe($_GET['s'],'de'));
define('TID',$_[0]);
define('ID',$_[1]);
define('P',$_[2]);
define('TIME',$_[3]);
define('HOST',$_[4]);
define('IP',$_[5]);
if(!$set['run']) {
    echo $set['offtext'];
    exit();
};
require 'channels.php';
define('DATA',$ch[TID][ID]['url'][P]);
if(!$ch[TID][ID] || time() - $set['time']  >= TIME) {
    header('HTTP/1.1 403');
    echo '<center><h1>'.$set['403text'].'</h1><hr></hr>'.$set['title'].'</center>';
} else {
    if($ch[TID][ID]['wc'] && $_GET['watchcode'] != $ch[TID][ID]['wc']) {
        echo '<center><font color="red"><h1>請鍵入觀看碼</font></h1></br><form action="player.php"><input type="text" name="watchcode" value="在這裡鍵入觀看碼"></br><input type="submit" value="完成"><input style="display:none;" name="s" value="'.$_GET['s'].'"></form></center>';
        exit();
    };
    if(preg_match('/^@jiexi@/',DATA[2])) {
        preg_match_all('/^@jiexi@(.*?)\.php|\?(.*?)$/',DATA[2],$data);
        parse_str($data[2][1],$datas);
        include($data[1][0].'.php');
        $playlink = cache();
    } else if(preg_match('/^@iframe@/',DATA[1])) {
        preg_match('/^@iframe@(.*?)$/',DATA[1],$data);
        $playlink = $data[1];
    } else {
        $playlink = DATA[2];
    };
    if(!$playlink) {
        $datas['id'] = 'BV1GJ411x7h7';
        $datas['p'] = '0';
        include('codes/error.php');
        $playlink = error();
    };
    if($ch[TID][ID]['icon']) {
        $icon = $ch[TID][ID]['icon'];
    } else {
        $icon = $set['noimg'];
    };
    if(DATA[1] == 'iframe') {
        echo '<script src="js/de.js"></script><script>document.write(\'<iframe width="100%" height="100%" allowfullscreen="allowfullscreen" mozallowfullscreen="mozallowfullscreen" msallowfullscreen="msallowfullscreen" oallowfullscreen="oallowfullscreen" webkitallowfullscreen="webkitallowfullscreen" src="\' + atob(de("'.en($playlink,'').'").replace(/'.en('','M').'/g,\'M\')) + \'"></iframe>\');</script>';
    } else if(DATA[1] == 'easyplayer') {
    echo '<script src="https://www.chaojizhibo.net/e/DownSys/js/EasyPlayer-element.min.js"></script><script src="js/de.js"></script><script>var str=de("'.en($playlink,'').'").replace(/'.en('','M').'/g,\'M\');var url=atob(str);document.write(\'<easy-player video-url="\' + url + \'" video-title="'.ID.'" poster="'.$icon.'" live="true"></easy-player>\');</script>';
    } else if(DATA[1] == 'ckplayer') {
        echo '<meta charset="utf-8" /><link rel="stylesheet" type="text/css" href="//ckplayer.com/public/static/ckplayer-x3/css/ckplayer.css"><script type="text/javascript" charset="utf-8" src="//ckplayer.com/public/static/ckplayer-x3/js/ckplayer.js"></script><script src="/js/de.js"></script><div class="video" style="width: 100%;height: 100%"></div><script type="text/javascript">var str=de("'.en($playlink,'').'").replace(/'.en('','M').'/g,\'M\');var url=atob(str);videoObject={poster:\''.$icon.'\',autoplay:true,live:true,plug:\'hls.js\',container:\'.video\',video:url,screenshot:true,menu:[{title:\''.$set['title'].'\',underline:true},{title:\'關於視頻\',click:\'aboutShow\'}],title:\''.ID.'\',playbackrateOpen:false,};new ckplayer(videoObject);</script>';
    } else if(DATA[1] == 'ckplayer-video') {
        echo '<meta charset="utf-8" /><link rel="stylesheet" type="text/css" href="//ckplayer.com/public/static/ckplayer-x3/css/ckplayer.css"><script type="text/javascript" charset="utf-8" src="//ckplayer.com/public/static/ckplayer-x3/js/ckplayer.js"></script><script src="/js/de.js"></script><div class="video" style="width: 100%; height: 100%;">播放容器</div><script>var str=de("'.en($playlink,'').'").replace(/'.en('','M').'/g,\'M\');var url=atob(str);var videoObject={container:\'.video\',poster:\''.$icon.'\',video:url};var player=new ckplayer(videoObject);player.webFull();</script>';
    } else if(DATA[1] == 'dplayer') {
        echo '<script src="/js/de.js"></script><style>#dplayer{width: 100%;height: 100%;}</style><div id="dplayer"></div><script src="/js/flv.min.js"></script><script src="/js/hls.min.js"></script><script src="/js/dash.all.min.js"></script><script src="/js/webtorrent.min.js"></script><script src="/js/DPlayer.min.js"></script><script>var str=de("'.en($playlink,'').'").replace(/'.en('','M').'/g,\'M\');var url=atob(str); const dp = new DPlayer({container: document.getElementById("dplayer"),live: true,autoplay: true,theme: "'.$set['theme'].'",hotkey: true,mutex: true,screenshot: true,logo: \''.$icon.'\',contextmenu: [{text: "'.$set['title'].'",link: "/"}],video: {url: url,type: "auto",},});</script>';
    } else if(DATA[1] == 'dplayer-customhls') {
        echo '<script src="/js/de.js"></script><style>#dplayer{width: 100%;height: 100%;}</style><div id="dplayer"></div><script src="/js/flv.min.js"></script><script src="/js/hls.min.js"></script><script src="/js/dash.all.min.js"></script><script src="/js/webtorrent.min.js"></script><script src="/js/DPlayer.min.js"></script><script>var str=de("'.en($playlink,'').'").replace(/'.en('','M').'/g,\'M\');var url=atob(str); const dp = new DPlayer({container: document.getElementById("dplayer"),autoplay: true,theme: "'.$set['theme'].'",hotkey: true,mutex: true,screenshot: true,logo: \''.$icon.'\',contextmenu: [{text: "'.$set['title'].'",link: "/"}],video: {url: url,type: "customHls",customType: {customHls: function (video, player) {const hls = new Hls();hls.loadSource(video.src);hls.attachMedia(video);},},},});</script>';
    } else if(DATA[1] == 'dplayer-video') {
        echo '<script src="/js/de.js"></script><style>#dplayer{width: 100%;height: 100%;}</style><div id="dplayer"></div><script src="/js/flv.min.js"></script><script src="/js/hls.min.js"></script><script src="/js/dash.all.min.js"></script><script src="/js/webtorrent.min.js"></script><script src="/js/DPlayer.min.js"></script><script>var str=de("'.en($playlink,'').'").replace(/'.en('','M').'/g,\'M\');var url=atob(str); const dp = new DPlayer({container: document.getElementById("dplayer"),autoplay: true,theme: "'.$set['theme'].'",hotkey: true,mutex: true,screenshot: true,logo: \''.$icon.'\',contextmenu: [{text: "'.$set['title'].'",link: "/"}],video: {url: url,type: "auto",},});</script>';
    } else if(DATA[1] == 'xvplayer') {
        echo '<script src="/js/de.js"></script><script src="https://www.xv-videos1.com/static-files/v-93622f21189/v3/js/skins/min/default.header.static.js"></script><div id="html5video" style="width: 100%;"></div><script src="https://www.xv-videos1.com/static-files/v3/js/i18n/xvplayer/zh.js"></script><script src="https://www.xv-videos1.com/static-files/v-2e0cb2af6b7/v3/js/skins/min/player.html5hls.static.js" onerror="xv.console.log(this.src + \' load failed\', \'Video page\');"></script><link rel="stylesheet" href="https://www.xv-videos1.com/static-files/v-dddc36fe56c/v3/css/player/html5.css"><script>var str=de("'.en($playlink,'').'").replace(/'.en('','M').'/g,\'M\');var url=atob(str);var html5player=new HTML5Player(\'html5video\',\'\');if(html5player){html5player.setVideoUrlLow(url);html5player.setThumbUrl(\''.$icon.'\');html5player.setSeekBarColor(\'red\');html5player.setStaticPath(\'https://www.xv-videos1.com/static-files/v-2e0cb2af6b7/v3/\');document.getElementById(\'html5video\').style.minHeight = \'\';html5player.initPlayer();}</script>';
    } else if(DATA[1] == 'aliplayer') {
        echo '<script src="/js/de.js"></script><link rel="stylesheet" href="https://g.alicdn.com/de/prismplayer/2.13.2/skins/default/aliplayer-min.css" /><script charset="utf-8" type="text/javascript" src="https://g.alicdn.com/de/prismplayer/2.13.2/aliplayer-min.js"></script><div id="J_prismPlayer"></div><script>var str=de("'.en($playlink,'').'").replace(/'.en('','M').'/g,\'M\');var url=atob(str); var player = new Aliplayer({"id": "J_prismPlayer","source": url,"isLive": true,"width": "100%","height": "100%","cover": "'.$icon.'","preload": true,"snapshot": true,});</script>';
    } else {
        echo '<script src="https://www.chaojizhibo.net/e/DownSys/js/EasyPlayer-element.min.js"></script><script src="js/de.js"></script><script>var str=de("'.en($playlink,'').'").replace(/'.en('','M').'/g,\'M\');var url=atob(str);document.write(\'<easy-player video-url="\' + url + \'" video-title="'.ID.'" poster="'.$icon.'" live=""></easy-player>\');</script>';
    };
};
file_put_contents('logs/log'.date('Y-m-d').'.txt',str_replace('\/','/',json_encode($_,JSON_UNESCAPED_UNICODE)).$_GET['watchcode'].$playlink.date('Y-m-d,H:i:s').PHP_EOL,FILE_APPEND);